package com.ssi.mrms.action;

import static com.opensymphony.xwork2.Action.SUCCESS;

import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Namespaces;
import org.apache.struts2.convention.annotation.Result;

import com.ssi.mrms.action.result.IResultType;

@Action(value = "/show", results = { @Result(name = SUCCESS, type = "bytesResult") })
@Namespaces(value = { @Namespace("/image") })
public class ImageAction extends BaseAction implements IResultType {
	private static final Logger logger = Logger.getLogger(ImageAction.class);
	private String imageId;

	public String execute() throws Exception {
		logger.info("ImageAction Home.");
		return SUCCESS;
	}

	public byte[] getBytes() {
		/*
		 * byte[] imageInByte = null; BufferedImage originalImage = null; try
		 * (ByteArrayOutputStream baos = new ByteArrayOutputStream();) { //
		 * originalImage = CaptchaUtils.createImage(this.key);
		 * ImageIO.write(originalImage, "jpg", baos); baos.flush(); imageInByte
		 * = baos.toByteArray(); baos.close(); } catch (IOException e) {
		 * logger.error(e.toString(), e); } return imageInByte;
		 */
		return null;
	}

	public String getContentType() {
		return "image/jpeg";
	}

	public String getImageId() {
		return imageId;
	}

	public void setImageId(String imageId) {
		this.imageId = imageId;
	}

	@Override
	public Map<String, String> getHeader() {
		// TODO Auto-generated method stub
		return null;
	}

}
